package day12;

import sun.security.krb5.internal.crypto.HmacSha1Des3KdCksumType;

import java.util.Arrays;
import java.util.Locale;

//本类是用来测试String的常用方法演示demo
public class TestString {
    public static void main(String[] args) {
        String s1 = "abc";
        char[] valuses = {'a', 'b', 'c'};
        String s2 = new String(valuses);
        System.out.println(s1);
        System.out.println(s2);
        //测试常用方法
        System.out.println(s1.hashCode());
        System.out.println(s2.hashCode());
        System.out.println(s1.equals(s2));
        System.out.println(s1.toString());
        System.out.println(s1.length());
        System.out.println(s1.toUpperCase());
        System.out.println(s1.toLowerCase());
        System.out.println(s1.startsWith("a"));
        System.out.println(s1.endsWith("c"));
        System.out.println(s1.charAt(0));

        String s3 = "abcbdbba";
        System.out.println(s3.indexOf("b"));
        System.out.println(s3.lastIndexOf("b"));
        System.out.println(s2.concat("cxy"));
        System.out.println(s2);//abc,说明上面的拼接是临时的，不会更改原串的内容
        String s4 = s2.concat("aaa");
        System.out.println(s4);
        String s5 = "afbfcfdfe";
        System.out.println(Arrays.toString(s5.split("f")));
        String s6 = "    hh   hhh     ";
        System.out.println(s6);
        System.out.println(s6.trim());
        String s7 = "abcdefgh";
        System.out.println(s7.substring(3));
        System.out.println(s7.substring(3, 6));
        System.out.println(String.valueOf(10));
        System.out.println(String.valueOf(80) + 10);
        byte[] bs = s7.getBytes();
        System.out.println(Arrays.toString(bs));

    }
}
